import request from '@/util/request'

import { Film } from '@/api/film/type.ts'

enum API {
  ALL_FILM = '/movie/page1',
  UPDATEUSER_URL = '/movie/update',
  ADDUSER_URL = '/movie/add',
  DELETEUSER_URL = '/movie/delete/',
  movieAddBidIsExist = '/movie/add/',
  BANNER_URL = '/movie/banner',
  ALL_FILM_LIST = '/show/movies',
}

//查询所有电影
export const reqFilmInfo = (data: any) =>
  request.post<any, any>(API.ALL_FILM, data)

// 添加或者更新电影
export const reqAddOrUpdateFilm = (data: Film) => {
  //携带参数有ID更新
  if (data.id) {
    return request.post<any, any>(API.UPDATEUSER_URL, data)
  } else {
    return request.post<any, any>(API.ADDUSER_URL, data)
  }
}
//上架
export const RequpdateFilmIsExist = (moiveId: number) =>
  request.get<any, any>(`${API.movieAddBidIsExist}${moiveId}`)
// 删除电影
export const reqRemoveMovie = (moiveId: number) =>
  request.delete<any, any>(`${API.DELETEUSER_URL}${moiveId}`)

//轮播图
export const reqBanner = () => request.get<string, any>(API.BANNER_URL)

export const reqFilmList = () => request.get<any, any>(API.ALL_FILM_LIST)
